package study.cdc.canal.support.blogic;

import com.alibaba.otter.canal.protocol.CanalEntry;
import lombok.extern.slf4j.Slf4j;
import study.cdc.canal.support.canal.dispater.EntryContext;

import java.util.List;

@Slf4j
public abstract class BaseBLogic implements BLogic {

    @Override
    public final void processBLogic(EntryContext entryContext,
                                    List<CanalEntry.Column> beforeColumnsLt,
                                    List<CanalEntry.Column> afterColumnsLt) {
        try {
            CanalEntry.EventType eventType = entryContext.getEventType();
            switch (eventType) {
                case INSERT:
                    onInsert(afterColumnsLt);
                    break;
                case UPDATE:
                    onUpdate(beforeColumnsLt, afterColumnsLt);
                    break;
                case DELETE:
                    onDelete(beforeColumnsLt);
                    break;
                default:
                    log.info("");
            }
        } catch (Exception ex) {
            log.error("", ex);
        } finally {
        }
    }
}
